package com.wang.mandkey.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.view.View;

import com.wang.mandkey.utils.ProjectEnvironment;
import com.wang.mandkey.utils.SharePersistent;
import com.wang.mandkey.utils.StringUtils;

public class DemoView extends View {

	private Paint mPaint = null;
	private Context mContext=null;

	public DemoView(Context context) {
		super(context);
		
		mPaint = new Paint();
		mPaint.setStyle(Style.STROKE);
		mPaint.setColor(Color.BLUE);
	}
	public DemoView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.mContext=context;
		setFocusable(true);
		mPaint = new Paint();
		mPaint.setStyle(Style.STROKE);
		mPaint.setColor(Color.BLUE);
		mPaint.setStrokeWidth(2);
		mPaint.setTextSize(20);
		mPaint.setAntiAlias(true);
//		TypedArray params = context.obtainStyledAttributes(attrs,R.styleable.mouseView);
//		// String title=params.getString(R.styleable.mouseView_title);
//		int backGroundColor = params.getColor(R.styleable.mouseView_back_ground_color, 0xffffff);
//		setBackgroundColor(backGroundColor);
//		params.recycle();
//        
//		int height=params.getInteger(R.styleable.mouseView_width, 200);
//		setLayoutParams(new RelativeLayout.LayoutParams(-1,height));
//		
//		mPaint = new Paint();
//		mPaint.setStyle(Style.STROKE);
//		mPaint.setColor(Color.BLUE);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		mPaint.setColor(Color.BLUE);
		mPaint.setStrokeWidth(2);
		
		float radios=ProjectEnvironment.FLOAT_BUTTON_RADIUS;
		String radioStr=SharePersistent.getPerference(mContext, ProjectEnvironment.STRING_PROJECT_RADIUS_KEY);
		if(!StringUtils.isEmpty(radioStr)){
			radios=Integer.parseInt(radioStr);
		}
		canvas.drawCircle(100, 100, radios, mPaint);
		mPaint.setColor(Color.RED);
		canvas.drawText("按键半径:"+radios, 20, 20, mPaint);
	}

	@Override
	public void invalidate() {
		super.invalidate();
	}


	public Paint getmPaint() {
		return mPaint;
	}

	public void setmPaint(Paint mPaint) {
		this.mPaint = mPaint;
	}
  
	
}
